package com.scqkxx.gamebox.activity.space.adapter;

import android.content.ContentValues;
import android.view.View;

import com.avos.avoscloud.AVObject;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scqkxx.gamebox.R;
import com.scqkxx.gamebox.activity.activities.utils.ActivityUtil;
import com.scqkxx.gamebox.activity.myself.MyselfEditNicknameActivity;

import java.text.SimpleDateFormat;
import java.util.List;

public class SearcPostionAdapter extends BaseQuickAdapter<AVObject ,BaseViewHolder> {

    public SearcPostionAdapter(int layoutResId, List<AVObject> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AVObject item) {
        helper.getView(R.id.line_posttion).setVisibility(View.GONE);

        helper.setText(R.id.tv_space_name, item.getString("name"));
        helper.setText(R.id.tv_goods, item.get("goodsNum")+"");
        helper.setText(R.id.tv_menbers, item.get("membersNum")+"");
        helper.setText(R.id.tv_space_time, new SimpleDateFormat("yyyy-MM-dd").format(item.getCreatedAt())+"建立");

        helper.convertView.setOnClickListener(view -> {
            ContentValues contentValues = new ContentValues();
            contentValues.put("spaceState" ,2);
            contentValues.put("belongGroupId",item.getInt("belongGroupId"));
            contentValues.put("objectId",item.getInt("spaceId")+"");
            contentValues.put("spaceId",item.getInt("spaceId"));
            ActivityUtil.switchTo(mContext,MyselfEditNicknameActivity.class,contentValues);
        });
    }
}
